package cn.yunhe.biz;

import cn.yunhe.dao.EmpDao;
import cn.yunhe.entity.Dept;
import cn.yunhe.entity.Emp;
import cn.yunhe.entity.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class EmpBiz {
    @Resource
    private EmpDao empDao;

    public List<Emp> getAllEmp(){
        return empDao.getAllEmp();
    }

    public List<Emp> searchEmp(Page page){
        if (page.getPageIndex()<1){
            page.setPageIndex(1);
        }
        page.setPageStart( (page.getPageIndex()-1)*page.getPageSize());
        return empDao.searchEmp(page);
    }

    public  Emp getEmpById(int id){
       return empDao.getEmpById(id);
    }

    public List<Dept> getAllDept(){
        return empDao.getAllDept();
    }

    public void updateEmp(Emp emp) {
        empDao.updateEmp(emp);
    }

    public void delEmp(Emp emp){
        empDao.delEmp(emp);
    }

    public void setEmpDao(EmpDao empDao) {
        this.empDao = empDao;
    }

    public  Integer getCount(){
        return empDao.getCounts();
    }
}
